package com.yesallchina.wxapp.officialaccount.api.beans;


import com.yesallchina.wxapp.officialaccount.api.enums.MessageEventTypeEnum;
import com.yesallchina.wxapp.officialaccount.utils.JacksonUtils;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.HashMap;
import java.util.Map;

@XmlRootElement(name = "xml")
public class TextMessage extends Message {

    private String Content;

    public TextMessage() {
        super();
        super.setMsgType(MessageEventTypeEnum.TEXT.getMsgType());
    }

    public TextMessage(String content) {
        super();
        super.setMsgType(MessageEventTypeEnum.TEXT.getMsgType());
        this.Content = content;
    }

    @XmlElement(name = "Content")
    public String getContent() {
        return Content;
    }

    public void setContent(String content) {
        Content = content;
    }


    @Override
    public String toCustomerMessage() {
        Map<String, Object> msg = new HashMap<>();
        msg.put("touser", getToUserName());
        msg.put("msgtype", MessageEventTypeEnum.TEXT.getMsgType());
        Map<String, Object> text = new HashMap<>();
        text.put("content", getContent());
        msg.put("text", text);
        return JacksonUtils.generate(msg);
    }

    public static void main(String[] args) {
        TextMessage message = new TextMessage("哈啊");
        System.out.println(message.toPassiveResponseXML());
    }
}
